package com.lzh.chatnote.common.mqConsumer;


import com.lzh.chatnote.common.constant.MQConstant;
import com.lzh.chatnote.common.domain.dto.LoginMessageDTO;
import com.lzh.chatnote.webSocket.service.WebSocketService;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author: lizhenhua
 *
 */
@RocketMQMessageListener(consumerGroup = MQConstant.LOGIN_MSG_GROUP,
        topic = MQConstant.LOGIN_MSG_TOPIC, messageModel = MessageModel.BROADCASTING)
@Component
public class MsgLoginConsumer implements RocketMQListener<LoginMessageDTO> {

    @Resource
    private WebSocketService webSocketService;


    @Override
    public void onMessage(LoginMessageDTO loginMessageDTO) {
        //System.out.println("授权完成尝试登陆用户 => " + loginMessageDTO);
        //尝试登录登录
        webSocketService.loginSuccess(loginMessageDTO.getCode(), loginMessageDTO.getUid());
    }

}
